<!-- 博客列表页 -->


<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>博客列表页</title>
    <link rel="stylesheet" href="css/common.css">
    <link rel="stylesheet" href="css/blog_list.css">
</head>
<body>
    <!-- 导航栏 -->
    <!-- 导航栏里面包含logo，标题，和一些按钮也就是跳转链接-->
    <!-- 为了实现左右排列，在logo和按钮之间加一个spacer作为占位器 -->
    <div class="nav">
        
        <!-- 放入图片D:/image/dog.png作为logo -->
        <img src="image/cat.png" alt="">
        <!-- span在行内定义一块区域 -->
        <span class="title">我的博客系统</span>
        <!-- 用来占据中间位置 -->
        <span class="spacer"></span>
        <a href="blog_list.html">主页</a>
        <a href="blog_edit.html">写博客</a>
        <a href="login.html">注销</a>
    </div>

    <!-- 版心 -->
    <div class="container">
        <!-- 左侧个人信息 -->
        <div class="container-left">
            <!-- 将个人信息放到.card div中 -->
            <div class="card">
                <img src="image/cat.png" class="avtar" alt="">
                <h3>xun</h3>
                <a href="https://blog.csdn.net/crazy_tan/">github 地址</a>
                <div class="counter">
                    <span>文章</span>
                    <span>分类</span>
                </div>
                <div class="counter">
                    <span>2</span>
                    <span>1</span>
                </div>
            </div>
        </div>

        <!-- 右侧内容详情 -->
        <div class="container-right">
            
        </div>
    </div>
    <script src="js/jquery.min.js"></script>
    <script src="js/common.js"></script>
    <script>
        $.ajax({
            type:"get",
            url:"blog",
            success:function(blogs){
                console.log(blogs);
                for(var blog of blogs){
                    var blogDiv = document.createElement("div");
                    blogDiv.className = "blog";
                    //标题
                    var titleDiv = document.createElement("div");
                    titleDiv.className = "title";
                    titleDiv.innerHTML = blog.title;
                    blogDiv.appendChild(titleDiv);
                    //日期
                    var dateDiv = document.createElement("div");
                    dateDiv.className = "date";
                    dateDiv.innerHTML = blog.createTime;
                    blogDiv.appendChild(dateDiv);
                    //摘要
                    var descDiv = document.createElement("div");
                    descDiv.className = "desc";
                    descDiv.innerHTML = blog.content;
                    blogDiv.appendChild(descDiv);
                    //查看全文
                    var detailA = document.createElement("a");
                    detailA.className = "detail";
                    detailA.href = "blog_detail.html?blogId="+blog.id;
                    detailA.innerHTML = "查看全文&gt;&gt;";
                    blogDiv.appendChild(detailA);

                    document.querySelector(".right").appendChild(blogDiv);
                }
            }
        });
        getUserInfo("list");
    </script>
</body>
</html>